﻿
Public Class var
    Public Shared Sub invoke(ByVal inlineScript As inlineScript, ByVal name As String, ByVal value As Object)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        assert(Not isemptystring(name), "name is an empty string.")
        inlineScript.addscript(network.http.contentType.textjavascript, "var_" + name, _
                               invoke(name, value) + ";")
    End Sub

    Public Shared Function invoke(ByVal name As String, Optional ByVal value As Object = Nothing, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        actionTarget += "var " + name
        Dim s As String = Nothing
        s = Convert.ToString(value)
        If Not isemptystring(s) Then
            actionTarget += "=" + s
        End If
        Return actionTarget
    End Function
End Class
